/**
 * Created by dqw on 2015/12/30.
 */

//列表开始
var dtGridColumns = [
    {
        id: 'id',
        title: 'ID',
        type: 'int',
        columnClass: 'text-center width-20',
        fastSort: true,
        fastQuery: false,
    },
    {
        id: 'orderId',
        title: '订单ID',
        type: 'number',
        headerClass: 'text-left',
        columnClass: 'text-left width-20',
        fastSort: false,
        fastQuery: false,
    },
    {
        id: 'operation',
        title: '操作',
        type: 'string',
        headerClass: 'text-left',
        columnClass: 'text-left width-20',
        fastSort: false,
        fastQuery: false,
    },
    {
        id: 'operationTime',
        title: '操作日期',
        type: 'date',
        format: 'yyyy-MM-dd HH:mm:ss',
        headerClass: 'text-left',
        columnClass: 'text-left',
        fastSort: true,
        fastQuery: true,
        fastQueryType: 'range'
    },
    {
        id: 'creator',
        title: '操作者',
        type: 'string',
        headerClass: 'text-left',
        columnClass: 'text-left width-20',
        fastSort: false,
        fastQuery: false,
    },
];

var dtGridOption = {
    lang: 'zh-cn',
    ajaxLoad: true,
    loadURL: ncGlobal.adminRoot + 'orderOperation/list.json',
    exportFileName: '订单操作日志列表',
    columns: dtGridColumns,
    gridContainer: 'dtGridContainer',
    toolbarContainer: 'dtGridToolBarContainer',
    pageSize: 10,
    pageSizeLimit: [10, 20, 50],
    ncColumnsType: {int:["id"],Timestamp:["operationTime"],BigDecimal:["buyPrice","sellPrice","profitCount"]}
};

var grid = $.fn.DtGrid.init(dtGridOption);
grid.fastQueryParameters = {};

//默认查询条件
grid.fastQueryParameters = {};
grid.fastQueryParameters['eq_order_id'] = $('#orderId').val();
//排序
grid.sortParameter.columnId = 'id';
grid.sortParameter.sortType = 1;
//列表结束

//操作处理开始
var OperateHandle = function () {
    function _bindEvent() {

        //模糊搜索
        $('#customSearch').click(function () {
            grid.fastQueryParameters['lk_name'] = $('#keyword').val();
            grid.pager.startRecord = 0;
            grid.pager.nowPage = 1;
            grid.pager.recordCount = -1;
            grid.pager.pageCount = -1;
            grid.refresh(true);
        });
    }

    //外部可调用
    return {
        bindEvent: _bindEvent
    }
}();
//操作处理结束

$(function () {
    //加载列表
    grid.load();
    //页面绑定事件
    OperateHandle.bindEvent();
});